home *** CD-ROM | disk | FTP | other *** search
- Path: chronicle.mti.sgi.com!austern
- From: thp@cs.ucr.edu (Tom Payne)
- Newsgroups: comp.std.c++
- Subject: Re: Referencing pointers after delete
- Date: 22 Mar 1996 14:09:50 PST
- Organization: University of California, Riverside
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <4iushh$q3@galaxy.ucr.edu>
- References: <4is60i$ft6@galaxy.ucr.edu> <4isibn$el3@engnews1.Eng.Sun.COM>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: 22 Mar 1996 18:46:09 GMT
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
- Content-Length: 1336
- X-Lines: 33
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMVMlmUy4NqrwXLNJAQH6GwH9HG7gvBuNKKBS1DAGMUPglASlREbz5Y3V
- XCS91lobaBNz4ZH4aQokLDtxMIc5I5Lsc7u32L/Gr/5vB2/QDLBe6w==
- =2gge
- Originator: austern@isolde.mti.sgi.com
-
- Steve Clamage (clamage@Eng.Sun.COM) wrote:
- : In article ft6@galaxy.ucr.edu, thp@cs.ucr.edu (Tom Payne) writes:
- : >.... It seems that to accomodate
- : >certain hardware-based validity checkers for pointers, the standard
- : >has precluded the possibility of portable software-based validity
- : >checking. IMHO an unfortunate decision.
- :
- : Even if the value of a pointer after its referent was deleted were
- : required to be valid, it is still not possible to write a portable pointer
- : validity checker for C or C++. Example, assuming that it is always safe
- : to read the value of any pointer:
- :
- : void foo(int* p) {
- : // is p valid?
- : }
- : How are you going to determine portably whether p is valid in foo?
-
- By passing it to a checking routine, of course. ;-) Given the curent
- standard, a call to such a routine can elicit undefined behavior in an
- otherwise portable program:
-
- void bar(int*& p) {
- checkOut(p); // p is passed by value to checkOut.
- p = 0;
- }
-
- I don't mean to imply that one can portably detect *all* invalid
- pointers, but with help from the compiler software-based solutions
- can give coverage that is as complete as those based on hardware.
- In either case, it is not particularly helpful that the behavior
- becomes undefined the moment an invalid value is detected.
-
- Tom Payne (thp@cs.ucr.edu)
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-